<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active{
            color: red;
        }
    </style>
</head>
<body>
    <div id="app">
        {{message}}
        <p>{{num}}</p>
        <p>{{bool}}</p>
        <div>{{bool ? 'a':'b'}}</div>
        <p>{{arr.find(item=>item.name==='张三')?.age }}</p>
        <div v-html="htmlStr"></div>
        <div>
            <input type="text" v-model="count">
            <div>{{count}}</div>
        </div>
        <div>
            <div v-if="color==='red'">red</div>
            <div v-if="color==='blue'">blue</div>
        </div>
        <div>
            <a v-bind:href="url">百度</a><!--:是v-bind的简写--> 
        </div>
        <div style="height: 100px;width: 100px;background-color: red;" id="div" v-on:click="clickDiv"><!--@是v-on的简写--> </div>
        <div>
            <div v-for="(item,index) in fruits" :key="index">{{index+1}}---{{item}}</div>
            <div v-for="item in user" :key="item">{{item.name}}---{{item.age}}</div>
        </div>
        <div style="display: flex; margin-top: 30px;">
            <select v-model="currentMenu">
                <option value="首页">首页</option>
                <option value="列表">列表</option>
                <option value="详情">详情</option>
            </select>
            <div style="padding: 0 10px" :style="{fontSize:item===currentMenu ? '20px':'14px'}" :class="{active:item===currentMenu}" v-for="item in menus" :key="item">{{item}}</div>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue!',
                num:1,
                bool:true,
                arr:[{name:'张三',age:20}],
                htmlStr:'<h1 id="h">222222222222</h1>',
                count:0,
                color:'red',
                url:'https://www.baidu.com',
                fruits:['apple','banana','orange'],
                user:[{name:'李四',age:30}],
                menus:['首页','列表','详情'],
                currentMenu:'首页'
            },
            methods:{
                clickDiv(){
                    console.log('点击了div')
                    let color=document.getElementById('div').style.backgroundColor
                    document.getElementById('div').style.backgroundColor=color==='blue'?'red':'blue'

                    document.getElementById('h').style.color='green'
                }
            }
        })
    </script>
</body>
</html>